let setItem
let getItem
const storage = {}

if (!window.localStorage) {
  setItem = (key, o) => {
    storage[key] = o
  }
  getItem = key => {
    return storage[key]
  }
} else {
  setItem = (key, o) => {
    window.localStorage.setItem(key, JSON.stringify(o))
  }
  getItem = key => {
    return JSON.parse(window.localStorage.getItem(key))
  }
}

export default {
  install (Vue) {
    Vue.prototype.$localStorage = {
      set: setItem,
      get: getItem
    }
  }
}
